import pagination from '@/views/pagination'  //分页组件
import router from '@/router'
import dialogForm from './edit'
import agentHttp from '@/utils/agentHttp.js'
export default {
  components:{dialogForm,pagination},
  name: 'finalTrial',
  created(){
    this.getTobeAddedContractOrder();
  },
  data() {
  	return {
      //表格字段
      tableData: [{
          qcpp:"汽车品牌",
          qczpp: '子品牌',
          qccxx: '汽车车型',
          qccx: '汽车车系',
          dcsl:'12',
          clzjg:"222000",
          shzt:"未通过",
          ys:"红色"
        }],
        
        //弹窗状态值
        isAdd:{bool:true},
        dialogFormVisible: {bool:false},
        query:{index:""},

        formLabelWidth:'120px',
        filter: {
           orderNumber:"",
           
        }, 
        searchForm:{
          endDate:"", 
          startDate:"",
          orderNumber:"",
          dealerName:"", 
          carBrand:"",     

        },
        carOrderId:"",
        dialogFormInfo:{},
        startDateOpt: {
          disabledDate(time) {
            return time.getTime() > Date.now() 
          }
        },
        endDateOpt:{
            disabledDate:(time)=>{
              return  time.getTime()< new Date(this.searchForm.startDate).getTime();
            }
        },
        resetFormStatus:false
        
  	}
  },
  methods: {
      handleEdit(index, row){
        this.isAdd.bool=true;
        this.query.index=index;
        //this.dialogFormVisible.bool=true; 
      
        this.carOrderId = row.id;   
        this.getOrderInfo();
      },
      handleSee(index, row){
        this.isAdd.bool=false;
        this.query.index=index;
        this.dialogFormVisible.bool=true;
        this.carOrderId = row.id;
      },
      getTobeAddedContractOrder( ){
        if(!this.resetFormStatus){
          var params=this.searchForm||{};    
          params.page=this.tableData.page||1;
          params.rows=this.tableData.rows||10; 
          agentHttp.post('adminApi/admin/contractinfo/get_tobe_added_contract_order',params ).then((data)=>{
                if(data.success){
                  this.tableData = data.data;
                } 
          });
        }
      },
      //添加合同
      getOrderInfo(){  
          agentHttp.get('adminApi/admin/contractinfo/get_order_contract_info/'+this.carOrderId ).then((data)=>{ 
                if(data.success){ 
                  this.dialogFormInfo = data.data; 
                  this.dialogFormVisible.bool  = true;
                } 
          });
      },
      changeQuey(){
        this.getTobeAddedContractOrder();
      },
      resetSearchForm(formName) {
        this.resetFormStatus=true;
        this.tableData.page=1;
        this.tableData.rows=10;
        this.$refs[formName].resetFields();
        this.$nextTick(_ =>{
          this.resetFormStatus=false;
          this.getTobeAddedContractOrder();
        })
      },
      startDateGet(date){
        this.searchForm.startDate = date;
        this.getTobeAddedContractOrder();
      },
      endDateGet(date){
        this.searchForm.endDate = date;
        this.getTobeAddedContractOrder();
      }
  } 
}
